package com.kkb.order.service;

import entity.Payment;
import io.github.resilience4j.bulkhead.annotation.Bulkhead;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;

@Service
@Slf4j
public class OrderService {
    @Bulkhead(name = "backendA", type = Bulkhead.Type.THREADPOOL)
    public CompletableFuture<Payment> getPay() throws InterruptedException {
        log.info("enter service---------------");
        Thread.sleep(10000L);
        log.info("exit service----------------");
        return CompletableFuture.supplyAsync(() -> new Payment(123,  "线程池隔离fallback"));
    }
}
